package org.mall.modules.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.mall.modules.product.entities.CommoditySku;

import java.util.List;

/**
 * @Description: 商品SKU
 * @Author: jeecg-boot
 * @Date:   2019-11-07
 * @Version: V1.0
 */
public interface CommoditySkuMapper extends BaseMapper<CommoditySku> {

	 boolean deleteByMainId(Long mainId);
	/**
	 * 删除一对多--更新
	 * @param mainId
	 */
	@Update("update product_sku set deleted = 1 where spu_id = #{mainId}")
	 boolean deleteByOneMainId(@Param("mainId") long mainId);
    
	 List<CommoditySku> selectByMainId(@Param("mainId") Long mainId);

	/**
	 * 管理端删除商品SKU
	 * @param asList
	 * @return
	 */
	void deleteBySkuId(@Param("list") List<String> asList);

    List<CommoditySku> queryGoodsBySpuIds(@Param("spuIds") List<Long> spuIds);

    boolean saveBatch(List<CommoditySku> skuList);

    @Update("update product_sku set status = #{status} where spu_id =  #{spuId}")
    void updateStatus(@Param("spuId") Long spuId, @Param("status") Integer status);

}
